// src/store/sagas/category.saga.ts
import axios from 'axios'
import { put, takeEvery } from 'redux-saga/effects'
import { API } from '../../config'
import { getCategorySuccess, GET_CATEGORY } from '../actions/category.action'
import { Category } from '../models/category'

function * handleGetCategory () {
    try {
        // 发起请求获取分类列表
        let response = yield axios.get<Category[]>(`${API}/categories`)
        yield put(getCategorySuccess(response.data))
    } catch (error) {
        
    }
}
export default function * categorySaga () {
    // 获取分类列表
    yield takeEvery(GET_CATEGORY, handleGetCategory)
}